package com.basic.business.memoRelation.service.impl;

import com.basic.business.common.constants.Constants;
import com.basic.business.common.redis.RedisCacheUtils;
import com.basic.business.memoRelation.domain.TOrdersMemoRelation;
import com.basic.business.memoRelation.mapper.TOrdersMemoRelationMapper;
import com.basic.business.memoRelation.service.ITOrdersMemoRelationService;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;

/**
 * 卖家备注Service业务层处理
 *
 * @author zhaoxy_jn@163.com
 */
@Service
public class TOrdersMemoRelationServiceImpl implements ITOrdersMemoRelationService {

    @Resource
    private TOrdersMemoRelationMapper tOrdersMemoRelationMapper;

    @PostConstruct
    public void init(){
        resetMemoCache();
    }

    public List<TOrdersMemoRelation> getNormalMemoRelation() {
        return tOrdersMemoRelationMapper.getNormalMemoRelation();
    }

    public void resetMemoCache() {
        // 清空缓存
        RedisCacheUtils.clearCache(Constants.MEMO_RELATION_REDIS_KEY + "*");
        // 加载缓存
        RedisCacheUtils.setCacheObject(Constants.MEMO_RELATION_REDIS_KEY, getNormalMemoRelation());
    }
}
